import java.util.Stack;

public class minStack {
    Stack<Integer> stack;
    Stack<Integer> minStack;
    public minStack() {
        stack = new Stack<>();
        minStack = new Stack<>();
    }

    public void push(int val) {
        stack.add(val);
        if(minStack.empty() || val <= minStack.peek()){
            minStack.add(val);
        }
    }

    public void pop() {

        if(stack.peek().equals(minStack.peek())){
            stack.pop();
            minStack.pop();
        }else{
            stack.pop();
        }
    }

    public int top() {
        return stack.peek();

    }

    public int getMin() {
        return minStack.peek();
    }
}
